package org.lee.validation.vo.resp;

import lombok.Data;
import lombok.Getter;

/**
 * Result
 *
 * @author dralee
 * @date 2021-12-24 15:28:26
 **/
@Data
public class Result {

    private int code;
    private String message;

    private Result(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Result success() {
        return new Result(0, "Ok");
    }

    public static <T> Result success(T data) {
        return new InnerResult(0, "Ok", data);
    }

    public static Result fail(int code, String message) {
        return new Result(code, message);
    }

    @Getter
    public static class InnerResult<T> extends Result {

        private T data;

        private InnerResult(int code, String message, T data) {
            super(code, message);
            this.data = data;
        }
    }
}
